package com.itheima.mapper;

import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface OrderMapper {
    @Select("select *from health_chuanzhi.t_order where id=#{id}")
    Order findById(Integer id);
   //@Select("select count (*)from health_chuanzhi.t_order where member_id = #{memberId} and orderDate = #{orderDate} and setmeal_id = #{setmealId} ")
   @Select("select count(*) from health_chuanzhi.t_order where member_id = #{memberId} and orderDate = #{orderDate} and setmeal_id = #{setmealId}")
    Integer countByMemberIdAndDateWithSetmeal(Integer memberId, LocalDate orderDate, Integer setmealId);
    @Insert("insert into health_chuanzhi.t_order (member_id, orderDate, orderType, orderStatus, setmeal_id) " +
            "VALUES (#{memberId},#{orderDate},#{orderType},#{orderStatus},#{setmealId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Order order);
}
